<template>
  <div class="history">
    <span>历史记录</span>
    <span style="color:red" @click="$store.commit('delectAll')">全部删除</span>
  </div>
  <ul>
    <li v-for="(item,index) in $store.state.historyList" :key="index" @click="check(item)"> &#x3000;{{item}} <i @click.stop="$store.commit('delect',index)">&#x3000;X&#x3000;</i></li>
  </ul>
</template>

<script>
export default {
  emits:['check'], // 事件集合（通俗的讲，多个重复事件）需要注册一下
  setup(props,{emit}) {
      const check = (val) => {
        emit('check',val);
      }
      return{
          check
      }
  },
};
</script>
<style lang="scss" scoped>
.history {
  display: flex;
  height: 40px;
  padding: 0 10px;
  justify-content: space-between;
  align-items: center;
}
ul {
  display: flex;
  flex-wrap: wrap;
  li {
    padding: 3px 6px;
    border-radius: 20px;
    border: 1px solid #ccc;
    margin-left: 10px;
  }
}
</style>